<%--
  Created by IntelliJ IDEA.
  User: ZhuChunXiao
  Date: 2017/12/8
  Time: 13:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
  String jsessionid = session.getId();
%>
<form id="form_businessTravel_finish" class="panel-body form-horizontal form-padding">
  <input type="hidden" name="businessTravelId" id="businessTravelId" value="${businessTravelId}"/>

  <div class="form-group">
    <label class="col-md-2 control-label">是否完成出差</label>
    <div class="col-md-6">
      <div class="radio">
        <input type="radio" id="isComplete1" name="isComplete" value="是" class="magic-radio" <c:if test="${businessTravel.isComplete=='是'}">checked</c:if> >
        <label for="isComplete1">是</label>
        <input type="radio" id="isComplete2" name="isComplete" value="否" class="magic-radio" <c:if test="${businessTravel.isComplete=='否'}">checked</c:if> >
        <label for="isComplete2">否</label>
      </div>
    </div>
  </div>

  <div class="form-group noDiv" style="display: none">
    <label class="col-md-2 control-label">未出差原因</label>
    <div class="col-md-6">
      <input type="text" name="failReason" id="failReason" class="form-control" placeholder="请输入未出差原因或上传附件" value="${businessTravel.failReason}">
    </div>
  </div>

  <div class="form-group noDiv" style="display: none">
    <label class="col-md-2 control-label">未出差原因附件</label>
    <div class="col-md-6">
      <input name="uploadify" id="failFileName" placeholder="" type="file" >
      <input name="failFileId" id="failFileId" style="display: none" value="${failFileId}">
    </div>
  </div>

  <div class="form-group yesDiv" style="display: none">
    <label class="col-md-2 control-label">出差小结</label>
    <div class="col-md-6">
      <input type="text" name="travelSummary" id="travelSummary" class="form-control" placeholder="请输入出差小结或上传附件" value="${businessTravel.travelSummary}">
    </div>
  </div>

  <div class="form-group yesDiv" style="display: none">
    <label class="col-md-2 control-label">出差小结附件</label>
    <div class="col-md-6">
      <input name="uploadify" id="summaryFileName" placeholder="" type="file" >
      <input name="summaryFileId" id="summaryFileId" style="display: none" value="${summaryFileId}">
    </div>
  </div>

</form>

<script>

  inputLoad({
    objId:"failFileName",
    entityName:"failFileIds",
    sourceId:"failFileId",
    jsessionid:"<%=jsessionid%>"
  });

  inputLoad({
    objId:"summaryFileName",
    entityName:"summaryFileIds",
    sourceId:"summaryFileId",
    jsessionid:"<%=jsessionid%>"
  });

  $(":radio[name='isComplete']").click(function(){
    if($(this).val()=='是'){
      $(".yesDiv").show();
      $(".noDiv").hide();
    }else{
      $(".yesDiv").hide();
      $(".noDiv").show();
    }
  });

  function fn_task_feedback_save(callback) {
    var tmp = $(":checked[name='isComplete']").val();
    if(!tmp){
      __toastr_error("请选择是否完成出差！");
      return false;
    }

    if(($(":checked[name='isComplete']").val()=='是' && $("#travelSummary").val()=="") && ($(":checked[name='isComplete']").val()=='是' && $("input[name='summaryFileIds']").val()=="")){
      __toastr_error("请输入出差小结或者上传附件！");
      return false;
    }

    if(($(":checked[name='isComplete']").val()=='否' && $("#failReason").val()=="") && ($(":checked[name='isComplete']").val()=='否' && $("input[name='failFileIds']").val()=="")){
      __toastr_error("请输入未出差原因或者上传附件！");
      return false;
    }

    __form_save('form_businessTravel_finish', '<%=path%>/com/businessTravel/saveFinish',function(data){
      if(data.state == 1){
        callback(data);
      } else {
        callback();
      }
    },function(){
      callback();
    });

  }

</script>
